package com.projects.api.common.model.result;

import com.projects.api.common.base.BaseResultConstant;
import lombok.Data;
import org.springframework.util.StringUtils;

@Data
public class ResultMsg<D> extends BaseResult {

    private D data;

    public ResultMsg(BaseResultConstant baseResultConstant) {
        super(baseResultConstant.getCode(), baseResultConstant.getSuccess(), baseResultConstant.getMessage());
    }

    public ResultMsg(BaseResultConstant baseResultConstant, String message) {
        super(baseResultConstant.getCode(), baseResultConstant.getSuccess(), message);
    }

    public ResultMsg(BaseResultConstant baseResultConstant, String message, D data) {
        super(baseResultConstant.getCode(), baseResultConstant.getSuccess(), StringUtils.isEmpty(message) ? baseResultConstant.getMessage() : message);
        this.data = data;
    }
}
